const dbutil = require('../../../libs/MyDB');

module.exports = {
    getMenuInfo: async function () {
        let menus = [];
        await dbutil.multiSelect('res_menu', ['menu_id', 'menu_name'])
            .then(
                result => {
                    menus = result;
                }
            )
        return {
            code: 0,
            msg: "查询成功",
            data: menus,
            count: menus.length,
        }
    },
    addMenu: async function(data){
        await dbutil.add('res_menu',{menu_name:data.menuname});

        return {
            code:200,
            msg: '添加成功',
        }
    },
    editMenu: async function(data){
        await dbutil.update('res_menu',`menu_id=${data.menuid}`,{menu_name:data.menuname});

        return {
            code:200,
            msg: '修改成功',
        }
    },
    delMenu: async function(data){
        await dbutil.del('res_menu',`menu_id=${data.menuid}`);

        return {
            code:200,
            msg: '删除成功',
        }
    }
}